package com.fh.service.order;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fh.dao.DaoSupport;
import com.fh.entity.OrderEntity;
import com.fh.entity.OrderGoodsSpecEntity;
import com.fh.entity.Page;
import com.fh.util.PageData;


/**
 * @ClassName: OrderService
 * @Description:(PC端订单管理的收款确认service)
 * @author: 张鹏强
 * @date: 2017-3-22 上午19:57:17
 * 
 */
@Service("orderService")
public class OrderService {
	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
    /*
     * 确认订单总条数
     */
	public int queryOrderCount(Page pd) throws Exception {
		return (Integer) dao.findForObject("OrderMapper.queryOrderCount", pd);
	}
    /*
     * 确认订单列表
     */
	public List<OrderEntity> querySureOrderList(Page pd) throws Exception {
		return (List<OrderEntity>) dao.findForList("OrderMapper.querySureOrderList", pd);
	}
	/*
	 * 订单配货总条数
	 */
	public int queryOrderPreCount(Page pd) throws Exception {
		return (Integer) dao.findForObject("OrderMapper.queryOrderPreCount", pd);
	}
	/*
	 * 订单配货列表
	 */
	public List<OrderEntity> queryPreOrderList(Page pd) throws Exception {
		return (List<OrderEntity>) dao.findForList("OrderMapper.queryPreOrderList", pd);
	}
	/*
	 * 订单发货总条数
	 */
	public int querySendOrderCount(Page pd) throws Exception {
		return (Integer) dao.findForObject("OrderMapper.querySendOrderCount", pd);
	}
	/*
	 * 订单发货列表
	 */
	public List<OrderEntity> querySendOrderList(Page pd) throws Exception {
		return (List<OrderEntity>) dao.findForList("OrderMapper.querySendOrderList", pd);
	}
	/*
	 * 修改订单的状态
	 */
	public int updateOrderStatus(PageData pd) throws Exception {
		return (Integer) dao.findForObject("OrderMapper.updateOrderStatus", pd);
	}
	/*
	 * 查询订单基本信息
	 */
	public OrderEntity findOneOrder(PageData pd) throws Exception {
		return (OrderEntity) dao.findForObject("OrderMapper.findOneOrder", pd);
	}
	/*
	 * 添加订单状态记录
	 */
	public Integer createOrderHistory(PageData pd) throws Exception {
		return (Integer) dao.save("OrderHistoryMapper.insertOrderHistory", pd);
	}
	/*
	 * 查询订单详情
	 */
	public List<OrderGoodsSpecEntity> OrderGoodsSpecEntity(PageData pd) throws Exception {
		return (List<OrderGoodsSpecEntity>) dao.findForList("OrderMapper.OrderGoodsSpecEntity", pd);
	}
	/*
	 * 更新商品库存量
	 */
	public Integer updateGoodsSpecInventory(PageData pd) throws Exception {
          return (Integer) dao.update("OrderHistoryMapper.updateGoodsSpecInventory", pd);		
	}
	/*
	 * 根据goodsSpecID获取goodsID
	 */
	public PageData findGoodsID(PageData pd) throws Exception {
		return (PageData) dao.findForObject("OrderHistoryMapper.findGoodsID", pd);
	}
	/*
	 * 更新商品销量
	 */
	public Integer updateGoodsSale(PageData pd) throws Exception {
		return (Integer) dao.update("OrderHistoryMapper.updateGoodsSale", pd);
	}
	/**
	 * 查看订单详情基本信息
	 * @param id
	 * @return
	 * @throws Exception 
	 */
	public OrderEntity findByOId(PageData pd) throws Exception {
		return (OrderEntity) dao.findForObject("OrderMapper.findOneOrder", pd);
	}
	

}
